package classtest;

public class Test3 {
    public static void main(String[] args) {
        //插入与替换
        //创建StringBuffer对象，在like后面添加 programming
        StringBuffer sb = new StringBuffer("I like Python").insert(6," programming");
        System.out.println(sb);
        //定义索引找到Python起始索引位置，将Python替换为Java
        int index = sb.indexOf("Python");
        //截取字符串
        sb.replace(index,sb.length(),"Java");
        System.out.println(sb);
    }
}
